package cn.yunhe.action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ServletActionContext;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.Map;

public class BasicAction extends ActionSupport {

    public Map<String,Object> getMapRequest(){
        return (Map<String, Object>) ActionContext.getContext().get("request");
    }

    public Map<String,Object> getMapSession(){
        return ActionContext.getContext().getSession();
    }

    public HttpServletRequest getRequest(){
        return ServletActionContext.getRequest();
    }

    public HttpSession getSession(){
        return  ServletActionContext.getRequest().getSession();
    }

    public HttpServletResponse getResponse(){
        HttpServletResponse response = ServletActionContext.getResponse();
        response.setContentType("text/html ; charset=UTF-8");
        return  response;
    }
}
